package com.mouse.magent.proxy.handler;


import com.mouse.magent.common.handler.CommonHandler;
import io.netty.channel.ChannelHandlerContext;

public class HttpProxyHandler extends CommonHandler {

    private ChannelHandlerContext httpCtx;

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        super.channelActive(ctx);
    }

    public HttpProxyHandler(ChannelHandlerContext httpCtx) {
        this.httpCtx = httpCtx;
    }


    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        httpCtx.writeAndFlush(msg);
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        httpCtx.close();
        super.channelInactive(ctx);
    }
}


